<template>
  <div class="order-item" @click="onView">
    <div class="title">
      <span class="van-ellipsis w-240">{{ orderData.storeName }}</span>
      <span class="status" :style="getStatusStyle()">{{
        orderData.statusInfo
      }}</span>
    </div>
    <div class="cake-info" v-if="orderData.meituanGoodsItem">
      <van-image class="img" :src="orderData.meituanGoodsItem.mainPic" alt="" />

      <div class="cake-info-content">
        <div class="row mb-10">
          <span class="name van-ellipsis">{{
            orderData.meituanGoodsItem.goodsName
          }}</span>
          <span class="num">x {{ orderData.meituanGoodsItem.num || 0 }}</span>
        </div>

        <div class="row">
          <span class="remark">{{
            orderData.meituanGoodsItem.description
          }}</span>
        </div>
      </div>
    </div>

    <div class="summary-info">
      <span class="c-999">下单时间: {{ orderData.createTime }}</span>
      <span class="c-333"
      >共{{ orderData.totalNum }}件商品
        <!-- 合计: <span class="fz-16 fw-bold">¥ {{ orderData.totalPriceYuan }}</span> -->
      </span>
    </div>
  </div>
</template>

<script>
import { defineComponent, reactive } from "vue";
import { useRouter } from "vue-router";
import { statusColorMap } from "@/const";

export default defineComponent({
  props: {
    orderData: {
      type: Object,
      default: () => {},
    },
  },
  setup(props) {
    const router = useRouter();
    const state = reactive({});
    const onView = () => {
      router.push({
        path: "/order/detail",
        query: { id: props.orderData.id },
      });
    };

    const getStatusStyle = () => {
      let color = statusColorMap[props.orderData.status] || "#000";
      return {
        color,
      };
    };
    return {
      state,
      onView,
      getStatusStyle,
    };
  },
});
</script>

<style lang="less" scoped>
.order-item {
  padding: 10px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 10px;
  .title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .status {
      font-size: 12px;
    }
  }
  .cake-info {
    display: flex;
    padding: 12px 0;
    margin: 12px 0;
    border-top: 1px solid #f9f8f8;
    border-bottom: 1px solid #f9f8f8;
    .img {
      width: 70px;
      height: 70px;
      margin-right: 8px;
    }
    &-content {
      flex: 1;
      .row {
        display: flex;
        justify-content: space-between;
        flex-wrap: nowrap;
      }
      .remark {
        font-size: 12px;
        display: inline-block;
        width: 180px;
        color: #999;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .price {
        color: #756e6e;
        font-weight: bold;
        font-size: 14px;
      }
      .name {
        display: inline-block;
        width: 180px;
        font-size: 14px;
      }
      .num {
        color: #756e6e;
        font-size: 14px;
      }
    }
  }
  .summary-info {
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
</style>
